package com.dubboClient.way1;

import com.base.User;
import com.base.UserService;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;

public class DubboConsumer {
    public static void main(String[] args) {
        //1、application
        ApplicationConfig applicationConfig = new ApplicationConfig("sample-consumer");
        //2、配置reference
        ReferenceConfig<UserService> referenceConfig = new ReferenceConfig<>();
        referenceConfig.setApplication(applicationConfig);
        referenceConfig.setInterface(UserService.class);
        String url = "dubbo://127.0.0.1:20880/com.dubboService.UserService?anyhost=true&application=sample-provider&bind.ip=127.0.0.1&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.dubboService.UserService&methods=getUser&pid=9504&release=2.7.4.1&side=provider&timestamp=1732430238846, dubbo version: 2.7.4.1, current host: 192.168.87.1";
        referenceConfig.setUrl(url);
        UserService userService = referenceConfig.get();
        User user = userService.getUser(1L);
        System.out.println(user);
    }
}
